<template>
    <div class="demo">    
        <h1 ref="refId1">haha</h1>
        <h1>学校{{name}}{{address}}</h1>
        <button @click="showRef">获取ref</button>
        <MyStudent ref="MyStudent"/>
    </div>
</template>

<script>
import Student from '../../../19单文件组件/Student.vue'
    import MyStudent from "./MyStudent"
    export default {
        name:"MySchool",
        data(){
            return {
                name:'zzz1',
                address:"zzzzzzzzfffffff"
            }
        },
        methods:{
            showRef(){
                //通过$refs获取到元素。
                //这个是拿到了真实dom元素
                console.log(this.$refs.refId1)
                console.log(this.$refs)
                //拿到的是VueComponent实例对象
                console.log(this.$refs.MyStudent)
            }
        },
        components:{
            MyStudent
        }
    }
</script>

<style>
    .demo{
        background-color: orange;
    }
</style>